﻿
// Copyright © 2009 Mehdi Golchin. All rights reserved.

namespace TinyMceWrapper.Configuration
{

    #region [ Imports ]

    using System.Configuration;
    using TinyMceWrapper;

    #endregion

    public sealed class TinyMceSection : ConfigurationSection
    {

        #region [ Local Fields ]

        private static readonly ConfigurationProperty ScriptPathProperty = new ConfigurationProperty("scriptPath", typeof(string), null,
            ConfigurationPropertyOptions.IsRequired);

        private static readonly ConfigurationProperty ScriptModeProperty = new ConfigurationProperty("scriptMode", typeof(string));

        private static readonly ConfigurationProperty DisplayModesProperty = new ConfigurationProperty("displayModes",
            typeof(TinyMceDisplayModeCollection));

        private static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();

        #endregion

        #region [ Constructors ]

        static TinyMceSection()
        {
            properties.Add(ScriptPathProperty);
            properties.Add(ScriptModeProperty);
            properties.Add(DisplayModesProperty);
        }

        #endregion

        #region [ Public Properties ]

        [ConfigurationProperty("scriptPath", IsRequired = true)]
        public string ScriptPath
        {
            get { return (string)this[ScriptPathProperty]; }
            set { this[ScriptPathProperty] = value; }
        }

        [ConfigurationProperty("scriptMode")]
        public string ScriptMode
        {
            get { return (string)this[ScriptModeProperty]; }
            set { this[ScriptModeProperty] = value; }
        }

        [ConfigurationProperty("displayModes")]
        public TinyMceDisplayModeCollection DisplayModes
        {
            get { return (TinyMceDisplayModeCollection)this[DisplayModesProperty]; }
        }

        protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
        {
            return (name == "xmlns");
        }

        #endregion

        #region [ Override Members ]

        protected override ConfigurationPropertyCollection Properties
        {
            get { return properties; }
        }

        #endregion

    }

}
